<?php
class Application_Model_Projects extends Zend_Db_Table_Abstract 
{
    protected $_name = 'projects';
    public function getAllProjects() {
        $select = $this->select()
                       ->from($this->_name);
        return $this->fetchAll($select)->toArray();
    }
    
    public function getAllCatProjects($id) {
        $select = $this->select()
                       ->from($this->_name)
                       ->where('id_category =?', intval($id));
        return $this->fetchAll($select)->toArray();
    }
    
    public function deleteSelectProject($id) {
        $this->delete('id ='. intval($id));
    }
    
    public function updateSelectProject($id, $data) {
        $this->update($data, 'id ='. intval($id));
    }
    
    public function addProject($data) {
        $this->insert($data);
        return $this->getAdapter()->lastInsertId();
    }
    
    public function getSelectProject($id) {
        $select = $this->select()
                       ->from($this->_name)
                       ->where('id =?', intval($id));
        return $this->fetchAll($select)->toArray();
    }
    
    public function addImages($data) {
        $this->_name = 'additional_images';
        $this->insert($data);        
    }
    
    public function getSliderImages($id) {
        $this->_name = 'additional_images';
        $select = $this->select()
                       ->from($this->_name)
                       ->where('id_project =?', intval($id));
        return $this->fetchAll($select)->toArray();
    }
}
?>
